<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    {js href='__STATIC__/jquery/jquery-1.11.0.min.js' /}
    {js href='__STATIC__/layui/layui.js' /}
    {CSS href="__STATIC__/layui/css/layui.css" /}
    {CSS href="__STATIC__/admin/css/global.css" /}
    {block name="jscss"}{/block}
</head>
<body>
<div style="padding: 10px;">
    <div class="layui-tab">
        <ul class="layui-tab-title">
            <li class="{eq name="$from_type" value="1"}layui-this{/eq}"><a href="{:url('mp/Material/getMeterialByImages',['type'=>$type,'param'=>$param,'from_type'=>'1'])}">微信服务器</a></li>
            <li class="{eq name="$from_type" value="0"}layui-this{/eq}"><a href="{:url('mp/Material/getMeterialByImages',['type'=>$type,'param'=>$param,'from_type'=>'0'])}">本地</a></li>
        </ul>
        <div class="layui-tab-content">
            {switch name="$type"}
            {case value="image"}
            <div class="layui-tab-item meterial-Lists-li layui-show">
                <ul>
                    {volist name="material" id="v"}
                    <li class="meterial-Lists-li" onclick="returnV('{$v.url}','{$param}','image')" style="display: inline-block; width: 120px;cursor:pointer;"><img style="width: 120px;height: 120px;" src="{$v.url}"> </li>
                    {/volist}
                </ul>
            </div>
            {/case}
            {case value="voice"}
            <table class="layui-table">
                <colgroup>
                    <col width="">
                    <col width="200">
                    <col width="70">
                </colgroup>
                <thead>
                <tr>
                    <th>语音名称</th>
                    <th>创建时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="material" id="v"}
                <tr>
                    <td>{$v.title}</td>
                    <td>{$v.create_time}</td>
                    <td style="text-align: center"><button onclick="returnV('{$v.media_id}','{$param}','voice')" class="layui-btn layui-btn-xs">选取</button></td>
                </tr>
                {/volist}
                </tbody>
            </table>
            {/case}
            {case value="video"}
            <table class="layui-table">
                <colgroup>
                    <col width="">
                    <col width="200">
                    <col width="70">
                </colgroup>
                <thead>
                <tr>
                    <th>视频名称</th>
                    <th>创建时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="material" id="v"}
                <tr>
                    <td>{$v.title}</td>
                    <td>{$v.create_time}</td>
                    <td style="text-align: center"><button onclick="returnV('{$v.media_id}','{$param}','voice')" class="layui-btn layui-btn-xs">选取</button></td>
                </tr>
                {/volist}
                </tbody>
            </table>
            {/case}
            {/switch}

        </div>
    </div>
    <div class="page">
        {$page|raw}
    </div>
</div>
<script>
    //    layui.use('element', function(){
    //        var $ = layui.jquery
    //            ,element = layui.element(); //Tab的切换功能，切换事件监听等，需要依赖element模块
    //
    //        //触发事件
    //        var active = {
    //            tabChange: function(){
    //                //切换到指定Tab项
    //                element.tabChange('demo', '22'); //切换到：用户管理
    //            }
    //        };
    //
    //        $('.site-demo-active').on('click', function(){
    //            var othis = $(this), type = othis.data('type');
    //            active[type] ? active[type].call(this, othis) : '';
    //        });
    //
    //        //Hash地址的定位
    //        var layid = location.hash.replace(/^#test=/, '');
    //        element.tabChange('test', layid);
    //
    //        element.on('tab(test)', function(elem){
    //            location.hash = 'test='+ $(this).attr('lay-id');
    //        });
    //
    //    });
    function returnV(value,paramName,type) {
        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
        parent.parent.controllerByVal(value,paramName,type);
        parent.controllerByValByImages(value,paramName,type);
        parent.layer.close(index);
    }

</script>
</body>
</html>